package com.example.mooctao.util;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.mooctao.fragment.CodeFragment;
import com.example.mooctao.fragment.PasswordFragment;
//在 ViewPager2 中管理多个 Fragment，实现密码登录页面和验证码登录页面的切换。
public class MyPagerAdapter extends FragmentStateAdapter {

    public MyPagerAdapter(@NonNull FragmentActivity fragmentActivity){
        super(fragmentActivity);
    }
    public Fragment createFragment(int position) {
        switch (position){
            case 0:
                return new PasswordFragment();
            case 1:
                return  new CodeFragment();
            default:
                return new PasswordFragment();
        }
    }

    @Override
    public int getItemCount() {
        return 2;
    }
}
